package com.decoration.basic.service.impl;

import com.decoration.basic.entity.DecPhaseInf;
import com.decoration.basic.entity.PhaseUsers;
import com.decoration.basic.mapper.DecCtctionPhaseMapper;
import com.decoration.basic.findCondition.DecPhaseFindCondition;
import com.decoration.basic.service.DecPhaseService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DecPhaseServiceImpl implements DecPhaseService {

    @Resource
    DecCtctionPhaseMapper decCtctionPhaseMapper;

    @Override
    public List<DecPhaseInf> findAll(DecPhaseFindCondition findCondition) {
        return decCtctionPhaseMapper.phaselist(findCondition.getCtcId());
    }

    @Override
    public int insert(DecPhaseInf decPhaseInf) {
        return 0;
    }

    @Override
    public int updateById(DecPhaseInf decPhaseInf) {
        return decCtctionPhaseMapper.updateVailedFlag(decPhaseInf);
    }

    @Override
    public int updateNextPhase(DecPhaseInf decPhaseInf) {
        decPhaseInf.setPhaseRank(decPhaseInf.getPhaseRank()+1);
        DecPhaseInf rest =decCtctionPhaseMapper.findNextPhase(decPhaseInf);
        if (rest == null){
            return 0;
        }
        decPhaseInf.setVaildFlag(1);
        return decCtctionPhaseMapper.updateNextPhase(decPhaseInf);
    }

    @Override
    public int deleteById(Integer phaseId) {
        return 0;
    }

    @Override
    public Integer getDecPhaseInfSize() {
        return null;
    }

    @Override
    public DecPhaseInf findPhaseById(String phaseId) {
        return decCtctionPhaseMapper.findPhaseById(phaseId);
    }

}
